const Router = require('koa-router');
const router = new Router();
const {db, QueryTypes} = require("../../models/db");

// 小票打印明细
router.post('/deliver/printDetail', async ctx => {
    let tenantId = ctx.user.tenantId;
    let print = [];
    let sql = `SELECT a.companyId,b.value from tenant_company a left join options b on a.companyId=b.tenantId   and b.name='system' where a.tenantId=${tenantId}`
    let data = await db.query(sql, {type: QueryTypes.SELECT})
    data.map(it => {
        let tid = it.companyId;
        let value = it.value ? JSON.parse(it.value) : {};
        let isPrint = value.printDetail ? value.printDetail : false;
        print.push({tenantId: tid, print: isPrint});
    })
    return ctx.suc('', print)
})




module.exports = router;
